#include <iostream>
#include <stack>
#include <string>

bool isBracketSequenceValid(const std::string& sequence) {
    std::stack<char> brackets;
    
    for (char bracket : sequence) {
        if (bracket == '(' || bracket == '[' || bracket == '{' || bracket == '<') {
            brackets.push(bracket);
        } else if (bracket == ')' || bracket == ']' || bracket == '}' || bracket == '>') {
            if (brackets.empty()) {
                return false;
            }
            
            char top = brackets.top();
            brackets.pop();
            
            if ((bracket == ')' && top != '(') ||
                (bracket == ']' && top != '[') ||
                (bracket == '}' && top != '{') ||
                (bracket == '>' && top != '<')) {
                return false;
            }
        }
    }
    
    return brackets.empty();
}

int main() {
    std::string sequence;
    std::cout << "vvedi posledovatelnost skobok: ";
    std::getline(std::cin, sequence);
    
    bool isValid = isBracketSequenceValid(sequence);
    std::cout << (isValid ? "True" : "False") << std::endl;
    
    return 0;
}
